package com.hzdesk.media.matvector.koreabatch.client.my_paperless.adapter;

import android.content.Context;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.hzdesk.media.matvector.koreabatch.client.my_paperless.R;

import java.util.List;

/**
 * Created by Administrator on 2018/8/8.
 * 杭州席媒科技有限公司  Developers  刘传华  10
 * 佛祖镇楼 bug辟易
 */

public class NoScrollViewPagerAdapter extends FragmentPagerAdapter {
    private Context context;
    private List<Fragment> list;
    private String[] titles = {"设备", "会议", "下载列表", "分享列表", "我的"};
    private int images[] ={R.drawable.devices_manager_list_selector,R.drawable.metting_list_selector,
            R.drawable.download_list_selector,R.drawable.share_list_selector,R.drawable.personal_center_selector};
    public NoScrollViewPagerAdapter(FragmentManager fm,Context context,List<Fragment> mdate) {
        super(fm);
        this.context = context;
        list = mdate;
    }

    @Override
    public Fragment getItem(int position) {
        return list.get(position);
    }

    @Override
    public int getCount() {
        return list == null ? 0:list.size();
    }

    /**
     * 自定义方法，提供自定义Tab
     *
     * @param position 位置
     * @return 返回Tab的View
     */
    public View getTabView(int position,TabLayout tab) {
        View v = LayoutInflater.from(context).inflate(R.layout.tab_custom, null);
        TextView textView = (TextView) v.findViewById(R.id.tv_title);
        ImageView imageView = (ImageView) v.findViewById(R.id.iv_icon);
        textView.setText(titles[position]);
       imageView.setImageResource(images[position]);
        //添加一行，设置颜色
        textView.setTextColor(tab.getTabTextColors());//
        return v;
    }

}
